﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project_V1
{
    public partial class FrmHistory : Form
    {
        public FrmHistory()
        {
            InitializeComponent();
            this.Load += FrmReport_Load;
        }

        private void FrmReport_Load(object sender, EventArgs e)
        {
            btn_Reports_Click(null, null);
        }

        #region 打开窗体方法,和主界面的方法一样
        private void OpenWindow(Form Frm)
        {
            Frm.TopLevel = false;
            Frm.FormBorderStyle = FormBorderStyle.None;
            Frm.Dock = DockStyle.Fill;
            Frm.Parent = this.MainPanel;
            Frm.Show();
        }

        private bool CloseWindow(string FrmName)
        {
            foreach (Control ct in this.MainPanel.Controls)
            {
                if (ct is Form)
                {
                    Form Frm = (Form)ct;
                    if (Frm.Name == FrmName)
                    {
                        return true;
                    }
                    else
                    {
                        Frm.Close();
                    }
                }
            }
            return false;
        }
        #endregion

        private void btn_Reports_Click(object sender, EventArgs e)
        {
            if (CloseWindow("FrmReports") == false)
            {
                OpenWindow(new FrmReports());
            }
        }

        private void btn_Graphs_Click(object sender, EventArgs e)
        {
            //if (CloseWindow("FrmGraphs") == false)
            //{
            //    OpenWindow(new FrmGraphs());
            //}
        }

        private void btn_Analyses_Click(object sender, EventArgs e)
        {
            //if (CloseWindow("FrmAnalyses") == false)
            //{
            //    OpenWindow(new FrmAnalyses());
            //}
        }

        private void MainPanel_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
